'use strict';

/* Controllers of Analysis of Login Data */

app
  .controller('AnalysisLoginCtrl', ['$scope', 'RESTService', function($scope, RESTService) {

	$scope.d = [ ['1',6],['2',6] ];
	$scope.ticks = [ [ '1', '06-01' ], [ '2', '06-02' ] ];
	$scope.loadData = function() {
	    RESTService.getResponse("/rest/summary/getLoginDataSummary?").then(function(response) {
	    	//console.log("2======$response: ", response);
	    	$scope.d = [];
	    	$scope.ticks = [];
	    	var i = 1;
	    	var c;
    		var s;
	    	angular.forEach(response, function(value) {
	    		c = value.loginTimes;
	    		s = value.shortLoginDate;
	    		$scope.d.push([i, c]);
	    		$scope.ticks.push([i, s]);
	    		i++;
	        });
	    	//console.log("2======$scope.d: ", $scope.d);
	    	//console.log("2======$scope.ticks: ", $scope.ticks);
	    });
	};
	$scope.loadData();
	
    $scope.d0_1 = [ [0,7],[1,6.5],[2,12.5],[3,7],[4,9],[5,6],[6,11],[7,6.5],[8,8],[9,7] ];
    $scope.d0_2 = [ [0,4],[1,4.5],[2,7],[3,4.5],[4,3],[5,3.5],[6,6],[7,3],[8,4],[9,3] ];
  }]);
